// 护理管理 / 院内活动

import r from '@/utils/request';
import type { ListParams, ListResponseType, ResponseType } from '../types';



enum API {
    list = '/play/list', //院内活动列表
    delAll = '/play/deleteAll',
    playget = '/play/get/',//单条院内活动信息
    del = '/play/delete/', //删除院内活动
    add = '/play/add', //添加院内活动
    update = '/play/update',//修改院内活动
    playType = '/playType/list',//活动分类
}
export interface playId{
    id:number
}

export interface playlistParams extends ListParams {

    name: string
    beginDate: string
    endDate: string
    type: number
    key: string

}

type PlaylistResType = ListResponseType<{
    id: number;
    companyId: number;
    title: string;
    addTime: string;
    type: number;
    typeName: string;
    content: any;
    addAccountId: number;
    addAccountName: string;
    elderly: Elderly[];
    pictures: any;
}>


export interface Elderly {
    id: number;
    playId: number;
    elderlyId: number;
    elderlyName: string;
    elderlyPhoto: any;
    begName: string;
    houseName: string;
    buildingName: string;
}
export interface AdressAddParams {
    name: string;
    qrcode: string;
}

type playgetResType = ResponseType<{
    id: number;
    companyId: number;
    title: string;
    addTime: string;
    type: number;
    typeName: any;
    content: string;
    addAccountId: number;
    addAccountName: any;
    elderly: Elderly[];
    pictures: Picture[];
}>



export interface Elderly {
    id: number;
    playId: number;
    elderlyId: number;
    elderlyName: string;
    elderlyPhoto: any;
    begName: string;
    houseName: string;
    buildingName: string;
}

export interface Picture {
    id: number;
    playId: number;
    picture: string;
}






export interface ElderlyAdd {
    elderlyId: number;
    elderlyName:string
}

export interface PictureAdd {
    picture: string;
}
export interface PlayAddParams {
    title: string;
    type:  number | null;
    addTime?:string;
    content: string;
    elderly: ElderlyAdd[];
    pictures: PictureAdd[];
}
type PlayAddResType = ResponseType<{
    id: number;
    companyId: number;
    title: string;
    addTime: string;
    type: number;
    typeName: any;
    content: string;
    addAccountId: number;
    addAccountName: any;
    elderly: ElderlyplayAdd[];
    pictures: PictureplayAdd[];
}>
export interface ElderlyplayAdd {
    id: number;
    playId: number;
    elderlyId: number;
    elderlyName: any;
    elderlyPhoto: any;
    begName: any;
    houseName: any;
    buildingName: any;
}

export interface PictureplayAdd {
    id: number;
    playId: number;
    picture: string;
}

export interface PlayUpdateParams {
    id: number;
    title: string;
    type: number | null;
    content: string;
    elderly: ElderlyAdd[];
    pictures: PictureAdd[];
}
type PlayUpdateResType = ResponseType<{
    id: number;
    companyId: number;
    title: string;
    addTime: string;
    type: number;
    typeName: any;
    content: string;
    addAccountId: number;
    addAccountName: any;
    elderly: ElderlyplayAdd[];
    pictures: PictureplayAdd[];
}>

type playTypeResType = ListResponseType<{
    id:   number;
    name: string;
}>




export function playlistAPI(params: playlistParams): Promise<PlaylistResType> {
    return r.get(API.list, params);
}
export function playgetAPI(id: number): Promise<playgetResType> {
    return r.get(API.playget + id);
}
export function DelplayAPI(id: number): Promise<ResponseType<null>> {
    return r.delete(API.del + id);
}
export function PlayAddAPI(params: PlayAddParams): Promise<PlayAddResType> {
    return r.post(API.add, params);
}


export function DelAllPlayAPI(id: number[]): Promise<ResponseType<null>> {
    return r.post(API.delAll, id);
}
export function FoodsUpdateAPI(params: PlayUpdateParams): Promise<PlayUpdateResType> {
    return r.put(API.update, params);
}

export function playTypeAPI(): Promise<playTypeResType> {
    return r.get(API.playType);
}